<!-- 引进图片插件 begin -->
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/js/uploadify/jquery.uploadify.min.js" ></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/js/upload.js" ></script>
<link rel="stylesheet" charset="utf-8" type="text/css" href="__PUBLIC__/admin/js/uploadify/uploadify.css"> 
<!-- 引进图片插件 end-->
<!-- 配置文件 -->
<script type="text/javascript" src="__PUBLIC__/admin/js/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__PUBLIC__/admin/js/ueditor/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
	var ue = UE.getEditor('container');
</script>
<style type="text/css">
#feng{ width: 100%; overflow: hidden; float: left; margin: 5px; }
.bg{ background: none; border: none;}
label{ font-size: 16px;}
.uploadify-button-text{ display: inline-flex; }
.uploadify-button-text button{ margin: -10px; }
.upviewer img{ height:90px; width: 120px; }
.upviewer ul{ margin:0px; padding:0px; }
.upviewer li{ margin:0px; padding:0px; position: relative; display:inline-block; width:120px; height:90px; background-position: center; background-size: contain; background-repeat: no-repeat; float: left; margin-right:10px; border:1px #ccc solid; background-color:#f0f0f0;}
.upviewer li a{ display:inline-block; position: absolute; bottom:0px; left:0px; text-align:center; width:100%; background-color:rgba(0,0,0,0.3); color:red; cursor: pointer; }
.upviewer li:hover a{ background-color:rgba(0,0,0,0.8); }
</style>
<!-- 引入时间插件 -->
<script src="__PUBLIC__/admin/js/My97DatePicker/WdatePicker.js"></script>

 <div class="container-fluid">
  <div class="row-fluid">
    <div class="span12">
    <form role="form" id="form" action="{:U('Award/update_award',array('id'=>$list['id'],'cid'=>$list['cid']))}" onsubmit="return validation()">    
    <div class="form-group">
      <label for="name">奖品名</label>
      <input type="text" class="form-control" value="{$list.name}" name="name" required="required" />
   </div>
   <div class="form-group">
      <label for="name">数量</label>
      <input type="text" class="form-control" value="{$list.num}" name="num" required="required" />
   </div>
    <div class="form-group">
      <label for="name">概率</label>
      <input type="text" class="form-control" value="{$list.percent}" name="percent" required="required" />
   </div>

	
	<div class="form-group">
      <label for="name">领取对象</label>
      <select name="cus_type">
      	<option value="0" <if condition="$list['cus_type'] eq 0">selected="selected"</if>>全部用户</option>
      	<option value="1" <if condition="$list['cus_type'] eq 1">selected="selected"</if>>优质用户</option>
      </select>
 	</div>
 	

   <div class="form-group">
      <label for="name">使用范围</label>
      <input type="text" class="form-control" value="{$list.area}"  name="area" required="required" />
   </div>
   <div class="form-group">
      <label for="name">使用条件</label>
      <input type="text" class="form-control"  value="{$list.tiaojian}" name="tiaojian" required="required" />
   </div>

  <div class="form-group">
      <label for="name">使用须知</label>
      <script id="container" name="xuzhi"  type="text/plain">
      	{$list.xuzhi}
									</script>
      
   </div>
   <div class="form-group">
      <label for="name">活动会场</label>
      <input type="text" class="form-control" value="{$list.huichang}" name="huichang" />
   </div>
  
  <div id="feng">
   <div class="form-group">
      <label for="upload"><span style="color: red;">*</span>活动会场图片<span style="color: red;">(只能有1张)</span></label>
      <input type="file" class="form-control" id="upload" placeholder="图片上传"> <br />
      <input type="hidden" name="cover" id="img">
      <div id="view" class="upviewer" style="height:200px;">{$list.img}</div>
     
     </div>
  </div>


   <div class="form-group">
      <label for="name">优惠券类型</label>
      <select name="type" id="tesetSelect" form="form">
        <option value="{$list.type}"> <if condition="$list['type'] eq '1'">打折券</if> <if condition="$list['type'] eq '2'">服务券</if>
              <if condition="$list['type'] eq '3'">节日生日券</if>
              <if condition="$list['type'] eq '4'">活动入场券</if></option>

        <option value="1">打折券</option>
        <option value="2">服务券</option>
        <option value="3">节日生日券</option>
        <option value="4">活动入场券</option>
      </select>
   </div>


     <div class="form-group">
      <label for="name">开始时间</label>
<!--       <input type="text" class="form-control" name="starttime" required="required" />
 -->      <input name="starttime" class="form-control" value="{$starttime}"  type="text"  onclick="WdatePicker({realDateFmt :'yyyy-MM-dd HH:mm:ss',dateFmt:'yyyy-MM-dd HH:mm:ss'})" required="required" />
       </div>
       <div class="form-group">
      <label for="name">结束时间</label>
      <!-- <input type="text" class="form-control" name="endtime" required="required" /> -->
      <input name="endtime" class="form-control"  type="text" value="{$endtime}"  onclick="WdatePicker({realDateFmt :'yyyy-MM-dd HH:mm:ss',dateFmt:'yyyy-MM-dd HH:mm:ss'})" required="required"  />
       </div> 
    <button type="submit" class="btn btn-default">提交</button>
</form>
    </div>
  </div>
</div>
<script type="text/javascript">

$(function(){
  initDelFile();
  initUploadify({ ID:'upload',url:"{:U('Upload/upload')}",success:function(obj){ 
    if(obj.s){
      $('#view').append('<li><img src="'+obj.d+'"/><a d_path="'+obj.d+'">删除</a></li>');
      initDelFile();
    }else{
      alert(obj.m);
    }
  } });
});

function initDelFile(){
  $('.upviewer li a').unbind('click').click(function(){
    if(!confirm('你确认删除吗?')) return false;
    var _this = $(this);
    var dpath = $(_this).attr('d_path');
    if(!dpath) return false;
    $.post('{:U('Upload/delfile')}',{filepath:dpath},function(obj){ 
      if(obj.s){ 
        $(_this).parents('li').remove();
      }else{
        alert(obj.m);
        $(_this).parents('li').remove();
      } 
    },'json');
  });
}
  function validation(){  
  var img=$('#view').html().trim();//获取值    
    var listimg=$('#img').val(img);//写入值
    var listnum=document.getElementById("view").getElementsByTagName("img");//验证数量
   
     /* if(img=="")
      {
      alert('请上传一张图');
       return false; 
      }*/
      if(listnum.length>1)
      {
        alert('列表图只能有一张');
         return false; 
      }
    
}


</script>